package tech.aistar.mapper.authordis;

import org.apache.ibatis.annotations.Select;
import tech.aistar.entity.authordis.NoteAuthor;
import tech.aistar.entity.authordis.Traveler;
import tech.aistar.entity.authordis.UserTable;

import java.util.List;
import java.util.Set;

/**
 * Created by lenovo on 2019/9/27.
 */
public interface INoteAuthorDisMapper {

    /**
     * 随机寻找达人,一条一条找,
     * @return
     */
    @Select("SELECT * \n" +
            "FROM traveler AS t1 JOIN (SELECT ROUND(RAND() * ((SELECT MAX(id) FROM traveler)-(SELECT MIN(id) FROM traveler))+(SELECT MIN(id) FROM note_author)) AS id) AS t2 \n" +
            "WHERE t1.id >= t2.id \n" +
            "ORDER BY t1.id LIMIT 16")
    List<Traveler> findAuthorRandom();

    /**
     * 通过用户id来查询用户
     * @param
     * @return
     */
    @Select("select * from user_table where id=#{value}")
    UserTable findUserInfoByUserId(Integer id);

    /**
     * 通过达人id查询其信息
     * @param id
     * @return
     */
    @Select("select * from note_author where id = #{value}")
    NoteAuthor findAuthorByAuthorId(Integer id);





}
